﻿using Common.Extension;
using Newtonsoft.Json;
using RabbitMQ.Client;
using System;
using System.Collections.Generic;
using System.Text;

namespace Common.RabbitMQ
{
    internal static class RabbitExtensionFunctions
    {
        public static IBasicProperties CopyTo(this IBasicProperties properties, IBasicProperties target)
        {
            target.Headers = properties.Headers.Clone();
            target.Expiration = properties.Expiration;
            target.AppId = properties.AppId;
            target.ClusterId = properties.ClusterId;
            target.ContentEncoding = properties.ContentEncoding;
            target.ContentType = properties.ContentType;
            target.CorrelationId = properties.CorrelationId;
            target.DeliveryMode = properties.DeliveryMode;
            target.MessageId = properties.MessageId;
            target.Persistent = properties.Persistent;
            target.Priority = properties.Priority;
            target.ReplyTo = properties.ReplyTo;
            if (properties.ReplyToAddress != null)
            {
                target.ReplyToAddress = properties.ReplyToAddress;
            }
            target.Timestamp = properties.Timestamp;
            target.Type = properties.Type;
            target.UserId = properties.UserId;
            return target;
        }
    }
}
